home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11681 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1004 b   |  31 lines

  1. Path: li.net!jeremy
  2. From: jeremy@newshost.li.net (Jeremy Markman)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Newbie needs help w/ARGV ARGC
  5. Date: 25 Mar 1996 20:06:28 GMT
  6. Organization: LI Net (Long Island Network)
  7. Message-ID: <4j6uc4$ehf@linet06.li.net>
  8. References: <4j4ja1$dc3@mtinsc01-mgt.ops.worldnet.att.net>
  9. NNTP-Posting-Host: linet04.li.net
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Raymond Joh (dslayer@worldnet.att.net) wrote:
  13. : I have spent three days attempting to determine why my command line
  14. : arguments  are failing...
  15.  
  16. You don't need to use the gets() function.  The values of argv[][] are 
  17. already initialized when the program runs.
  18.  
  19. For example:
  20.  
  21. void main(int argc, char *argv[])
  22.  {
  23.   if (argc > 1)
  24.     printf("%s\n",argv[1]);
  25.  }
  26.  
  27. This will print the first command line argument.  Remember that the 
  28. program itself is the first argument, so that argc == 1 when no 
  29. additional parameters are added.  Accordingly, argv[0] is the name of the 
  30. program and argv[1] is the FIRST command line argument...
  31.